﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace Red.Controls.Converters
{
    public sealed class NameToResourceConverter : IValueConverter
    {
        #region IValueConverter implementation

        public object Convert( object value, Type targetType, object parameter, CultureInfo culture )
        {
            if ( value == null )
            {
                return null;
            }

            object resource = Application.Current.TryFindResource( value );
            return resource;
        }

        public object ConvertBack( object value, Type targetType, object parameter, CultureInfo culture )
        {
            throw new NotImplementedException();
        }

        #endregion IValueConverter implementation
    }
}
